// wait_group 实现有条件的等待
#include <workflow/WFFacilities.h>
#include <workflow/WFTaskFactory.h>
#include <workflow/WFHttpServer.h>
#include <iostream>
#include <signal.h>
using std::cout;
using std::cerr;
static WFFacilities::WaitGroup waitGroup(1);
void handler(int signum){
    cout << "done\n";
    waitGroup.done();
}
void process(WFHttpTask * serverTask){
    //serverTask是服务端任务 是分离的
    //cout << "process is called!\n";
}
int main(){
    signal(SIGINT,handler);
    // 构造了一个server对象
    WFHttpServer server(process);
    // 开启监听
    if(server.start(1234) == 0){
        cout << "server start success!\n";
        waitGroup.wait(); //阻塞住主线程
        server.stop(); // 停止监听
    }
    else{
        perror("server start");
        return -1;
    }
    return 0;
}
